<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()	+ path + "/";%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <base href="<%=basePath%>">
	<title><s:text name="sys.app_title" /></title>
	<%@include file="../include/contentheader.jsp"%>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<link rel="stylesheet" type="text/css" href="css/main.css" />
	<link rel="StyleSheet" type="text/css" href="css/dtree.css" />
	<!-- DTree -->
	<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
	<script type="text/javascript" src="js/app.js"></script>
	<script type="text/javascript" src="js/dtree.js"></script>
	<!-- DWR -->
	<script type="text/javascript" src="dwr/engine.js"></script>
	<script type="text/javascript" src="dwr/util.js"></script>
	<script type="text/javascript" src="dwr/interface/departmentDwrJs.js"></script>
	<script type="text/javascript">
		function doClose(did,dname){
			if(did != undefined && dname != undefined){
				window.returnValue = did+','+dname;
			}else{window.returnValue = "";}
			window.close();
		}
	</script>
	</head>

	<body onload="buildTree()">
	<input type="button" onclick="doClose();" value="取消" />
		<div class="mainContainer">
			<div class="headerTitle">
				请先选择部门
			</div>
			<div class="dtreeDiv" id="myTree" style="width: 200px;height: 400px;" onclick="">
				<script type="text/javascript">	
				dtree = new dTree('dtree');
				function buildTree(){
	   				departmentDwrJs.getAllDepartment(function(departmentList) {
	   				dtree.add(0, -1, '广元电业局',"javascript:doClose(\'"+000+"\',\'"+'广元电业局'+"\')");
	    			for(var i=0; i<departmentList.length; i++){
	        			for(var j=0; j<departmentList.length; j++){
		        			var name = departmentList[j].depname;
	            			if(departmentList[i].depid==departmentList[j].depparentid){
	            				dtree.add(departmentList[j].depid,departmentList[j].depparentid,name,"javascript:doClose(\'"+departmentList[j].depid+"\',\'"+name+"\')");
	        				}
	            		}
	    			}
	    			inner = dtree.toString();
	    			showBuildTree();
	    			});
	    		}
				function showBuildTree(){
					myTree.innerHTML = inner;
		  	 	}
			</script>
			</div>
		</div>
	</body>
</html>